package com.ekuaitu.kuaitustaff.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ekuaitu.kuaitustaff.R;
import com.ekuaitu.kuaitustaff.bean.CarTaskfinishBean;

import java.util.List;

public class CarPopTypeAdapter extends BaseAdapter {

    private LayoutInflater mInflater;
    private List<String> list;
    private TextView tv_item;
    private String isfromwhere;

    private List<CarTaskfinishBean.AttachmentBean.TaskListBean> taskList;

    public CarPopTypeAdapter(Context context, String isfromwhere) {
        this.mInflater = LayoutInflater.from(context);
        this.isfromwhere = isfromwhere;


    }

    public CarPopTypeAdapter(Context context, List<CarTaskfinishBean.AttachmentBean.TaskListBean> taskList, String isfromwhere, boolean flag) {
        this.mInflater = LayoutInflater.from(context);
        this.taskList = taskList;
        this.isfromwhere = isfromwhere;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        if (taskList != null && taskList.size() != 0) {
            return taskList.size();
        } else {
            return 0;
        }
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub

        if (taskList != null && taskList.size() != 0) {
            return taskList.get(arg0);
        } else {
            return 0;
        }

    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {

            holder = new ViewHolder();

            convertView = mInflater.inflate(R.layout.pop_checkcarstate_item, null);

            holder.tv_item = (TextView) convertView.findViewById(R.id.tv_item);

            convertView.setTag(holder);

        } else {

            holder = (ViewHolder) convertView.getTag();
        }


        if (taskList.size() != 0) {
            holder.tv_item.setText(taskList.get(position).getInstruction());
        }

        return convertView;
    }

    public class ViewHolder {
        public TextView tv_item;
    }
}